/**
 * 
 */
package com.celephais.common.server.model;

import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.InheritanceStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Text;

/**
 * @author Eugene Shen
 * The DAO that corresponds to BasicModelUI.
 * Created this level because there tends to be a lot of classes that have
 * these basic fields.
 */
@PersistenceCapable
// Makes sure fields will be stored in subclasses' tables.
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class BasicModel extends PersistentObject {

	@Persistent
	private String name;
	
	@Persistent
	private Text desc;
	
	public BasicModel() {
		super();
	}
	
	public BasicModel(BasicModel rhs) {
		this();
		setName(rhs.getName());
		setDesc(rhs.getDesc());
	}
	
	public BasicModel(Key key, String name, String desc) {
		super(key);
		setName(name);
		setDesc(desc);
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public Text getDesc() {
		return desc;
	}
	public void setDesc(Text desc) {
		this.desc = desc;
	}
	public void setDesc(String desc) {
		if (desc == null) {
			this.desc = null;
		}
		else {
			this.desc = new Text(desc);
		}
	}
}
